home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: August 14, 1996
- //
- // Description:
- // This is a helper script to perfrom the cutKey command
- // using the various options that have been set
- //
- // Input Arguments:
- // int action 0 - just execute the command
- // 1 - show the option box dialog
- // 2 - return the drag command
- //
- // Return Value:
- // None.
- //
-
- proc setOptionVars (int $forceFactorySettings)
- {
- keySetOptionBoxCommon( { "cutKey",
- "unknown",
- "setOptionVars",
- $forceFactorySettings } );
-
-
- // -options
- //
- if ($forceFactorySettings || !`optionVar -exists cutKeyOption`) {
- optionVar -stringValue cutKeyOption "keys";
- }
-
- // help images
- //
- if ($forceFactorySettings || !`optionVar -exists cutKeyHelpPictures`) {
- optionVar -intValue cutKeyHelpPictures 0;
- }
- }
-
- global proc cutKeySetup (string $parent, string $selectionConnection, int $forceFactorySettings)
- {
- // Retrieve the option settings
- //
- setOptionVars( $forceFactorySettings );
-
- setParent $parent;
-
- keySetOptionBoxCommon( { "cutKey", $selectionConnection, "setup" } );
-
- // -option
- //
- string $option = `optionVar -query cutKeyOption`;
- int $attach = 1;
- int $connect = 0;
-
- if (substring ($option, 1, 4) == "keys") {
- radioButtonGrp -edit -select 1 method;
- }
- else {
- radioButtonGrp
- -edit
- -select 2
- method;
- if ($option == "curveCollapse") {
- $attach = 2;
- }
- else if ($option == "curveConnect") {
- $attach = 2;
- $connect = 1;
- }
- }
- radioButtonGrp -edit -select $attach adjustment;
- checkBoxGrp -e -value1 $connect connect;
-
- // help images
- //
- int $pictures = `optionVar -q cutKeyHelpPictures`;
- checkBoxGrp -e -value1 $pictures helpPictures;
-
- // Now get all the dependent widgets in the right
- // enabled/disabled/collapsed/expanded state
- //
- cutKeyWidgetsEnable ($selectionConnection);
- }
-
- global proc cutKeyCallback( string $parent, int $doIt,
- string $selectionConnection,
- int $fromGraphEditor,
- int $performAction )
- {
- setParent $parent;
-
- keySetOptionBoxCommon( { "cutKey", $selectionConnection, "callback" } );
-
- // -option
- //
- string $option;
- if (`radioButtonGrp -query -select method` == 1) {
- $option = "keys";
- }
- else {
- $option = "curve";
- }
-
- if (`radioButtonGrp -query -select adjustment` == 2) {
- if( `checkBoxGrp -query -value1 connect` ) {
- $option = $option + "Connect";
- } else {
- $option = $option + "Collapse";
- }
- }
-
- optionVar -stringValue cutKeyOption $option;
-
- // help
- //
- int $pictures = `checkBoxGrp -query -value1 helpPictures`;
- optionVar -intValue cutKeyHelpPictures $pictures;
-
- if( $doIt ) {
- performCutKeyArgList 1 { (string) $performAction,
- $selectionConnection,
- (string) $fromGraphEditor };
- string $tmpCmd = "performCutKeyArgList 1 {\"";
- $tmpCmd += $performAction + "\", \"";
- $tmpCmd += $selectionConnection + "\", \"";
- $tmpCmd += $fromGraphEditor + "\"}";
- addToRecentCommandQueue $tmpCmd "Cut Key";
- }
- }
-
- global proc cutKeyHelpPictures ()
- {
- int $doPictures = (`checkBoxGrp -q -value1 helpPictures` &&
- `checkBoxGrp -q -enable helpPictures`);
-
- if( $doPictures == 0 ) {
- frameLayout -e -collapse yes methodPictureFrame;
- frameLayout -e -collapse yes adjustmentPictureFrame;
- return;
- }
-
- int $method = `radioButtonGrp -q -select method`;
- int $adjustment = `radioButtonGrp -q -select adjustment`;
-
- string $adjustmentPicture = "CCP";
- string $methodPicture;
-
- if( $method == 1 ) {
- $adjustmentPicture = $adjustmentPicture + "cutKeys";
- $methodPicture = "CCPkeyframesOnly.xpm";
- } else {
- $adjustmentPicture = $adjustmentPicture + "cutCurve";
- $methodPicture = "CCPcurveExact.xpm";
- }
-
- if( $adjustment == 2 ) {
- if( `checkBoxGrp -q -value1 connect` ) {
- $adjustmentPicture = $adjustmentPicture + "Connect.xpm";
- } else {
- $adjustmentPicture = $adjustmentPicture + "Collapse.xpm";
- }
- } else {
- $adjustmentPicture = $adjustmentPicture + ".xpm";
- }
-
- picture -e -image $methodPicture methodPicture;
- picture -e -image $adjustmentPicture adjustmentPicture;
-
- frameLayout -e -collapse no methodPictureFrame;
- frameLayout -e -collapse no adjustmentPictureFrame;
- }
-
-
- global proc cutKeyDoSelectionChanged (string $selectionConnection)
- //
- // Description:
- // Since timeRange is irrelevant when there are
- // picked keyframes, collapse the timeRange
- // when there are. (This is hooked in to a SelectionChanged
- // trigger.)
- //
- {
- keySetOptionBoxCommon( { "cutKey", $selectionConnection, "selectionChanged" } );
-
- if( `keyframe -q -sl -kc` > 0) {
- radioButtonGrp -e -enable2 false -select 1 method;
- radioButtonGrp -e -enable2 false -select 1 adjustment;
- } else if( `radioButtonGrp -q -enable method` ) {
- radioButtonGrp -e -enable2 true method;
- }
- }
-
-
- global proc cutKeyWidgetsEnable (string $selectionConnection)
- //
- // Description:
- // These are the widgets that get enabled and
- // disabled based on the certain states. Put them
- // here so they're all in one place.
- //
- {
- keySetOptionBoxCommon( { "cutKey", $selectionConnection, "enable" } );
-
- // Options frame
- //
- int $enableIt = ( `radioButtonGrp -q -select timeRange` != 1 );
- frameLayout -e -enable $enableIt optionsFrame;
-
- // Collapse adjustment
- //
- $enableIt = (( `radioButtonGrp -q -select method` == 2 ) &&
- ( `radioButtonGrp -q -enable2 method` ));
- radioButtonGrp -e -enable2 $enableIt adjustment;
- if( !$enableIt && `radioButtonGrp -q -enable method` ) {
- radioButtonGrp -e -select 1 adjustment;
- }
-
- // Connect Check box
- //
- $enableIt = (( `radioButtonGrp -q -select adjustment` == 2 ) &&
- ( `radioButtonGrp -q -enable2 adjustment` ));
- checkBoxGrp -e -enable $enableIt connect;
-
- cutKeyHelpPictures;
- }
-
- proc string cutKeyWidgets( string $tabLayout, string $selectionConnection, int $fromGraphEditor )
- {
- global int $gOptionBoxTextColumnWidthIndex;
-
- setParent $tabLayout;
-
- string $tabForm = `columnLayout -adjustableColumn true`;
-
- keySetOptionBoxCommon( { "cutKey", $selectionConnection, "widgets", $fromGraphEditor } );
-
- frameLayout -bv no -lv no -collapsable no optionsFrame;
- columnLayout -adjustableColumn true;
-
- checkBoxGrp -label "Help Images" -ncb 1 -value1 off -l1 ""
- -cc1 "cutKeyHelpPictures;"
- helpPictures;
-
- radioButtonGrp -numberOfRadioButtons 2 -label "Method"
- -label1 "Keys"
- -cc1 ("cutKeyWidgetsEnable " + $selectionConnection)
- -label2 "Segments"
- -cc2 ("cutKeyWidgetsEnable " + $selectionConnection) method;
-
- frameLayout -bv no -lv no -collapsable yes -collapse yes
- methodPictureFrame;
-
- columnLayout -columnAttach "left" $gOptionBoxTextColumnWidthIndex;
- picture methodPicture;
- setParent ..;
- setParent ..;
-
- radioButtonGrp -numberOfRadioButtons 2 -label "Adjustment"
- -label1 "None"
- -cc1 ("cutKeyWidgetsEnable " + $selectionConnection)
- -label2 "Collapse"
- -cc2 ("cutKeyWidgetsEnable " + $selectionConnection)
- adjustment;
-
- checkBoxGrp -label "Connect" -ncb 1 -l1 "" -value1 off
- -cc1 "cutKeyHelpPictures;" connect;
-
- frameLayout -bv no -lv no -collapsable yes -collapse yes
- adjustmentPictureFrame;
-
- columnLayout -columnAttach "left"
- $gOptionBoxTextColumnWidthIndex;
-
- picture adjustmentPicture;
-
- setParent ..;
- setParent ..;
-
- setParent ..;
-
- setParent ..;
-
- return $tabForm;
- }
-
- proc cutKeyOptions ( string $selectionConnection, int $performAction, int $fromGraphEditor )
- {
- // Customisation options
- //
- // Name of the command for this option box (think of it as the base class)
- string $commandName = "cutKey";
- // Title for the option box window
- string $optionBoxTitle = "Cut Keys Options";
- // Title for the apply button
- string $applyTitle = "Cut keys";
-
- // Build the option box "methods"
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // Build the window, with a tab layout
- //
- string $widgetList[] = `getStandardWindow $optionBoxTitle 0 "noOptions"`;
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Make the form invisible while we create the widgets in the window
- //
- formLayout -e -vis false $widgetList[1];
-
- // Attach the widgets. No tab layout needed.
- //
- cutKeyWidgets $widgetList[2] $selectionConnection $fromGraphEditor;
-
- // Attach the standard buttons
- //
- string $buttonList[] = `addStandardButtons $commandName $applyTitle
- $widgetList[1] $widgetList[2] "noOptions"`;
-
- // attach commands to the standard buttons
- //
- // Save
- //
- button -e -c ($callback + " " + $widgetList[0] + " false \"\" " +
- $fromGraphEditor + " " + $performAction +
- "; hideOptionBox()") $buttonList[3];
-
- // Close
- //
- button -edit -command hideOptionBox $buttonList[2];
-
- // Reset
- //
- button -edit -command ($setup + " " + $widgetList[0] + " " + $selectionConnection + " true")
- $buttonList[1];
-
- // Do It
- //
- button -edit -command ($callback + " " + $widgetList[0] + " true \"" +
- $selectionConnection + "\"" + $fromGraphEditor +
- " " + $performAction) $buttonList[0];
-
- // Make the form layout visible so we can see what we built, and
- // reset the template
- //
- formLayout -e -vis true $widgetList[1];
- setUITemplate -popTemplate;
-
- // Customize the 'Help' menu item text.
- // This is called from 3 different places so look at the selection
- // connection to try to figure out which one.
- //
- if (match ("graphEditor", $selectionConnection) != "") {
- setOptionBoxHelpTag( "GraphCut" );
- } else if (match ("dopeSheet", $selectionConnection) != "") {
- setOptionBoxHelpTag( "DopeCut" );
- } else {
- setOptionBoxHelpTag( "KeysCutKeys" );
- }
-
- // Call the setup "method" to fill in the current settings
- //
- eval (($setup + " " + $widgetList[0] + " " + $selectionConnection + " false"));
- showOptionBox();
- showWindow $widgetList[0];
-
- if( $fromGraphEditor ) {
- cutKeyDoSelectionChanged($selectionConnection);
- scriptJob -protected -event "SelectionChanged"
- ("cutKeyDoSelectionChanged " + $selectionConnection + "; cutKeyWidgetsEnable " + $selectionConnection + ";")
- -parent $widgetList[2];
- }
- }
-
- proc string assembleCmd( string $selectionConnection, int $fromGraphEditor,
- string $options )
- {
- // doCutKeyArgList takes a string array.
- //
- string $cmd = "doCutKeyArgList 3 { " +
- "\"" + `optionVar -q cutKeyWhichRange` + "\"" +
- ",\"" + `optionVar -q cutKeyRange` + "\"" +
- ",\"" + `optionVar -q cutKeyOption` + "\"" +
- ",\"" + `optionVar -q cutKeyHierarchy` + "\"" +
- ",\"" + `optionVar -q cutKeyControlPoints` + "\"" +
- ",\"" + `optionVar -q cutKeyShapes` + "\"" +
- ",\"" + `optionVar -q cutKeyUseChannelBox` + "\"" +
- ",\"" + $selectionConnection + "\"" +
- ",\"" + $options + "\"" +
- ",\"" + $fromGraphEditor + "\"" +
- ",\"" + `optionVar -q cutKeyDriven`+ "\"" +
- " };";
-
- return $cmd;
- }
-
- global proc string performCutKeyArgList (string $version, string $args[])
- //
- // Input Arguments:
- // $version: The version of this option box. Used to know how to
- // interpret the $args array.
- // "1" : $action, $selectionConnection, $fromGraphEditor
- //
- // $args
- // Version 1
- // [0] $action 0 - do the command
- // 1 - show the option box
- // 2 - return the drag command
- // 3 - do the command (bufferCurve version)
- // 4 - show the option box (bufferCurve version)
- // 5 - return the drag command (bufferCurve version)
- // [1] $selectionConnection name of selection connection to use
- // unless $options has "bufferCurve" in which
- // case this is the name of the editor
- // [2] $fromGraphEditor true if being called from the graph editor
- //
- // Return Value:
- // The actual command to execute.
- //
- {
- int $versionNum = $version;
-
- int $action = $args[0];
- string $selectionConnection = $args[1];
- int $fromGraphEditor = $args[2];
-
- string $cmd = "";
-
- switch( $action ) {
- case 0:
- setOptionVars( false );
- $cmd = assembleCmd( $selectionConnection, $fromGraphEditor,
- "noOptions" );
- eval( $cmd );
- break;
- case 1:
- cutKeyOptions( $selectionConnection, 0, $fromGraphEditor );
- break;
- case 2:
- setOptionVars( false );
- $cmd = assembleCmd( $selectionConnection, $fromGraphEditor,
- "noOptions" );
- break;
- case 3:
- setOptionVars( false );
- $cmd = assembleCmd( $selectionConnection, $fromGraphEditor,
- "bufferCurve" );
- eval( $cmd );
- break;
- case 4:
- cutKeyOptions( $selectionConnection, 3, $fromGraphEditor );
- break;
- case 5:
- setOptionVars( false );
- $cmd = assembleCmd( $selectionConnection, $fromGraphEditor,
- "bufferCurve" );
- break;
- }
- return ($cmd);
- }
-